package gold.contest;

import gold.utils.InputUtil;

import java.util.Arrays;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC6075 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int maximumBags(int[] capacity, int[] rocks, int additionalRocks) {
            int n = capacity.length;
            for (int i = 0; i < n; i++) {
                capacity[i] -= rocks[i];
            }

            Arrays.sort(capacity);
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if (additionalRocks >= capacity[i]) {
                    cnt++;
                    additionalRocks -= capacity[i];
                }
            }

            return cnt;
        }
    }

    public void run() {
        System.out.println(new Solution().maximumBags(InputUtil.toIntegerArray("[2,3,4,5]"), InputUtil.toIntegerArray("[1,2,4,4]"), 2));
        System.out.println(new Solution().maximumBags(InputUtil.toIntegerArray("[10,2,2]"), InputUtil.toIntegerArray("[2,2,0]"), 102));
    }

    public static void main(String[] args) throws Exception {
        LC6075 an = new LC6075();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
